import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import { createI18n } from 'vue-i18n';
import enLocale from '@/assets/locales/en-US.json';
import zhLocale from '@/assets/locales/zh-CN.json';
import * as ElementPlusIconVue from '@element-plus/icons-vue';
import 'element-plus/dist/index.css';

//app
const app = createApp(App);

//element-plus
for (const [key, component] of Object.entries(ElementPlusIconVue)) {
  app.component(key, component);
}

//router
app.use(router);

//vue-i18n
const i18n = createI18n({
  legacy: false,
  locale: import.meta.env.VITE_LANGUAGE,
  fallbackLocale: 'en-US',
  messages: {
    'en-US': enLocale,
    'zh-CN': zhLocale,
  },
});
app.use(i18n);

app.mount('#app');
